/* map.h */

/* Handles management and display of 'map' of game area */

#ifndef __map_h
#define __map_h

#include "DeskLib:Core.h"

#include "man.h"

/* Size of playing area */
#define MAPSIZEX 20
#define MAPSIZEY 15

/* How playing area is stored */
typedef union {
  char coords[MAPSIZEY][MAPSIZEX];
  char quickref[MAPSIZEX * MAPSIZEY];
} map_array;

/* Number of left shifts needed to convert map coords to pixels */
#define MAPPIX 4

/* Possible items in map */
typedef enum {
  map_BLANK,
  map_EXPLO1,map_EXPLO2,map_EXPLO3,map_EXPLO4,map_EXPLO5,map_EXPLO6,
  map_EXPLO7,map_EXPLO8,map_EXPLO9,map_EXPLO10,map_EXPL11,map_EXPLO12,
  map_TIMER0,map_TIMER1,map_TIMER2,map_TIMER3,map_TIMER4,
  map_TIMER5,map_TIMER6,map_TIMER7,map_TIMER8,map_TIMER9,
  map_TIMER10,map_TIMER11,map_TIMER12,map_TIMER13,map_TIMER14,
  map_TIMER15,map_TIMER16,map_TIMER17,map_TIMER18,map_TIMER19,
  map_TIMER20,map_TIMER21,map_TIMER22,map_TIMER23,map_TIMER24,
  map_TIMER25,map_TIMER26,map_TIMER27,map_TIMER28,map_TIMER29,
  map_TIMER30,map_TIMER31,map_TIMER32,map_TIMER33,map_TIMER34,
  map_TIMER35,map_TIMER36,map_TIMER37,map_TIMER38,map_TIMER39,
  map_BOMBOFF,map_DETONATOR,
  map_STEEL,map_BRICK,map_EARTH
} map_items;

/* Number of types of icon above */
#define map_NUMTYPES (map_EARTH + 1)

/* Needs to be called once to set up table of which sprite to display for
   which map item */
void map_init_table(void);

/* Returns FALSE if unable to load */
BOOL map_load_level(char *filepath,int level,
     		    int *time_limit,char *title,char *password);

/* Plots whole map on screen as quickly as possible */
void map_draw(int vga);

/* Puts an item in the map */
void map_place_item(int x,int y,map_items item);

/* Works out whether man or bomb can move to new position (x,y) in
   direction (dx,dy).
   man = TRUE if testing man, FALSE if testing bomb.
   Sets status if gets free or blown up
 */
BOOL map_loc_free(int x,int y,int dx,int dy,BOOL man,
     		  man_status *status,BOOL *pushing,BOOL *detonator);

/* Scan map to carry out any explosions
   Returns TRUE if man gets blown up
 */
BOOL map_scan(void);

#endif
